package com.atguigu.gulimall.product.service.impl;

import com.atguigu.gulimall.product.entity.MshoppingcartEntity;
import org.springframework.stereotype.Service;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.atguigu.common.utils.PageUtils;
import com.atguigu.common.utils.Query;

import com.atguigu.gulimall.product.dao.MproductPictureDao;
import com.atguigu.gulimall.product.entity.MproductPictureEntity;
import com.atguigu.gulimall.product.service.MproductPictureService;
import org.springframework.util.StringUtils;


@Service("mproductPictureService")
public class MproductPictureServiceImpl extends ServiceImpl<MproductPictureDao, MproductPictureEntity> implements MproductPictureService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {


        String key = (String) params.get("key");
        QueryWrapper<MproductPictureEntity> mproductPictureEntityQueryWrapper = new QueryWrapper<MproductPictureEntity>();
        if(!StringUtils.isEmpty(key)){
            mproductPictureEntityQueryWrapper.eq("product_id",key).or().like("intro",key);
        }

        IPage<MproductPictureEntity> page = this.page(
                new Query<MproductPictureEntity>().getPage(params),
                new QueryWrapper<MproductPictureEntity>()
        );

        return new PageUtils(page);
    }

}